#!/usr/bin/env python
# -*-coding:UTF-8-*-
# Author: chenzuoqing@126.com
# Create: 2018/8/13 15:07
# File  : alise_views.py

"""

"""

from rest_framework import viewsets
from rest_framework.filters import SearchFilter


class ReturnFormatMixin(object):
    ret = {'status': 0, 'msg': '', 'data': {}}


class BaseView(ReturnFormatMixin, viewsets.ModelViewSet):
    queryset = None
    serializer_class = None
    permission_classes = []
    filter_backends = [SearchFilter]
    search_fields = []

    def perform_create(self, serializer):
        serializer.create(self.request.data)

    def perform_update(self, serializer):
        serializer.update(self.get_object(), self.request.data)
